package com.ihr360.commons.model.type;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ihr360.commons.model.annotation.EnumData;
import com.ihr360.commons.serializer.jackson.EnumDataSerializer;

import java.math.RoundingMode;
@EnumData
@JsonSerialize(using = EnumDataSerializer.class)
public enum RoundType {
    ROUND("四舍五入", "round"),
    CEIL("进位取整", "Ceil"),
    FLOOR("取整", "Floor");

    private String title;
    private String engTitle;

    private RoundType(String title, String engTitle) {
        this.title = title;
        this.engTitle = engTitle;
    }

    public String getTitle() {
        return this.title;
    }

    public String getEngTitle() {
        return this.engTitle;
    }

    public RoundingMode toRoundingMode() {
        switch(this.ordinal()) {
            case 1:
                return RoundingMode.CEILING;
            case 2:
                return RoundingMode.FLOOR;
            default:
                return RoundingMode.HALF_UP;
        }
    }
}